<?php

namespace app\api\model\questions;

use app\api\model\Models;
use think\db\Query;
use app\api\traits\model\questions\QuestionCategory as QuestionCategoryTraits;

class QuestionCategory extends Models
{
    use QuestionCategoryTraits;

    /*
     * 定义全局的查询范围
     * @var array
     */
    protected $globalScope = ['noDisplay'];

    /**
     * 设置全局不显示字段
     * @param Query $query
     * @return void
     */
    public function scopeNoDisplay( Query $query )
    {
        $query->field('create_at,update_at', true);
    }

    /**
     * 获取为章节题库的题目
     * @param Query $query
     * @param int $pid
     * @return void
     */
    public function scopePid( Query $query, int $pid )
    {
        $query->where('pid', $pid);
    }

}
